package com.edouardbataille.open.result
{
	import __AS3__.vec.Vector;
	
	public class ResultSet
	{
		private var offSet : uint = 0;
		
		private var rowOffSet : uint = 0;
		
		public var lastInsertId : int;
		
		public function ResultSet(nbField : int)
		{
			if (nbField > 0 && nbField < 0xFF)
			{
				_metaDatas = new Vector.<SqlMetadata> (nbField);
				results = new Vector.<Result> ();
			}
		}
		
		private var _metaDatas : Vector.<SqlMetadata>;
		
		private var results : Vector.<Result>;
		
		public function beforeFirst () : void
		{
			offSet = 0;
		}
		
		public function hasNext () : Boolean
		{
			return results && offSet < results.length;
		}
		
		public function next () : Result
		{
			return results[offSet++];
		}
		
		public function addMeta (value : SqlMetadata, pos : uint) : void
		{
			_metaDatas[pos] = value;
		}
		
		public function get metaDatas () : Vector.<SqlMetadata>
		{
			return _metaDatas;
		}
		
		public function addRow (value : Result) : void
		{
			results[rowOffSet++] = value;
		}

	}
}